package com.ysy.logistics.entities.system.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ysy.logistics.entities.system.vo.MenuVO;
import com.ysy.logistics.entities.system.SysUser;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @ClassDescription:
 * @Author:姚斯羽
 * @Create:2025/3/12 14:35
 **/
@Data
@Schema(name = "SysUserDTO", description = "用户实体类返回")
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SysUserDTO {

    @Schema(description = "用户id")
    private String id;
    @Schema(description = "用户名")
    @TableField(value = "user_name")
    private String username;
    @Schema(description = "昵称")
    private String nickname;
    @Schema(description = "头像")
    private String avatar;
    @Schema(description = "电话")
    private String iPhone;
    @Schema(description = "token")
    private String token;


    @Schema(description = "角色")
    private List<String> rolesName;
    @Schema(description = "菜单")
    private List<MenuVO> menuVOTree;
    /**
     * 将SysUser对象转换为SysUserDTO对象
     * @param sysUser
     * @return
     */
    public static SysUserDTO convertToSysUserDTO(SysUser sysUser){
        return SysUserDTO.builder()
                .id(sysUser.getId())
                .username(sysUser.getUsername())
                .nickname(sysUser.getNickname())
                .avatar(sysUser.getAvatar())
                .iPhone(sysUser.getPhone())
                .build();
    }
}
